<?php

class SiteController extends Controller {

    public function init() {
    	if (Yii::app()->user->isGuest)
    		Yii::app()->theme = LOGIN_THEME;
    	else
        	Yii::app()->theme = ADMIN_THEME;

        parent::init();
    }

    /**
     * Declares class-based actions.
     */
    public function actions() {
        return array(
            // captcha action renders the CAPTCHA image
            // this is used by the contact page
            'captcha' => array(
                'class' => 'CCaptchaAction',
                'backColor' => 0xEBF4FB,
            ),
        );
    }

    /**
     * This is the default 'index' action that is invoked
     * when an action is not explicitly requested by users.
     */
    public function actionIndex() {
        // renders the view file 'protected/views/site/index.php'
        // using the default layout 'protected/views/layouts/main.php'
        $this->render('index');
    }

    /**
     * Displays the contact page
     */
    public function actionContact() {
//        $contact = new ContactForm;
//        if (isset($_POST['ContactForm'])) {
//            $contact->attributes = $_POST['ContactForm'];
//            if ($contact->validate()) {
//                Yii::app()->getModule('email');
//                $email = new Email;
//                $email->to = Yii::app()->params['adminEmail'];
//                $email->from = $email->replyTo = $contact->email;
//                $email->subject = $contact->subject;
//                $email->message = $contact->body;
//                $email->send();
//
//                Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
//                $this->refresh();
//            }
//        }
//        $this->render('contact', array('contact' => $contact));
        $this->render('contact');
    }

}